<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>
	<title>Manager</title>
</h:head>
<body>
	<ui:composition template="/pages/common/commonLayout.xhtml">
		<ui:define name="content">
			<h:form>
				<p:panel header="Filtr" toggleable="true" closable="false" toggleSpeed="500" 
					closeSpeed="500" widgetVar="panel1" style="margin-bottom:20px">
					<table>
						<tr>
							<td><h:outputLabel for="firstName" value="Imie" /></td>
							<td><p:inputText id="firstName"
									value="#{managerMB.firstName}" /></td>
							<td><h:outputLabel for="lastName" value="Nazwisko:" /></td>
							<td><p:inputText id="lastName" value="#{managerMB.lastName}" /></td>
						</tr>
						<tr>
							<td><h:outputLabel for="gender" value="Plec:" /></td>
							<td><p:selectOneMenu id="gender" value="#{managerMB.gender}">
									<f:selectItem itemValue="#{null}" />
									<f:selectItems value="#{enumBean.genderValues}" var="gender"
										itemValue="#{gender}" itemLabel="#{gender.label}" />
								</p:selectOneMenu></td>
							<td><h:outputLabel for="spec" value="Specjalnosc:" /></td>
							<td><p:selectOneMenu id="spec" value="#{managerMB.spec}">
									<f:selectItem itemValue="#{null}" />
									<f:selectItems value="#{enumBean.specializationValues}"
										var="spec" itemValue="#{spec}" itemLabel="#{spec.label}" />
								</p:selectOneMenu></td>
						</tr>
						<tr>
							<td><h:outputLabel for="pesel" value="Pesel:" /></td>
							<td><p:inputText id="pesel" value="#{managerMB.pesel}" /></td>
						</tr>
						<tr>
							<td><p:commandButton id="reset" value="Wyczysc"
									action="#{managerMB.reset}" ajax="false" /></td>
							<td><p:commandButton id="filter" value="Filtruj"
									action="#{managerMB.filtering}" ajax="false" /></td>
							<td><p:commandButton id="all" value="Pokaż wszystkich"
									action="#{managerMB.getAll}" ajax="false" /></td>
						</tr>
					</table>
				</p:panel>
				<p:panel header="Lista" toggleable="true" closable="false" toggleSpeed="500" 
					closeSpeed="500" widgetVar="panel2" style="margin-bottom:20px">
					<p:dataTable var="doc" value="#{managerMB.filtered}"  paginator="true"
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         rowsPerPageTemplate="5,10,15,20" rows="10">
						<p:column headerText="Imie i nazwisko">
							<h:outputText value="#{doc.firstName} #{doc.lastName}" />
						</p:column>
						<p:column headerText="Pesel">
							<h:outputText value="#{doc.pesel}" />
						</p:column>
						<p:column headerText="Plec">
							<h:outputText value="#{doc.gender.label}" />
						</p:column>
						<p:column headerText="Specjalizacja">
							<h:outputText value="#{doc.spec.label}" />
						</p:column>
						<p:column headerText="Akcje">
							<p:commandButton icon="ui-icon-search" action="/pages/manager/manageDoctorSchedule?faces-redirect=true">
								<f:setPropertyActionListener target="#{managerMB.chosen}" value="#{doc}"/>
							</p:commandButton>
							<p:commandButton icon="ui-icon-pencil" action="/pages/doctor/editDoctor?faces-redirect=true">
								<f:setPropertyActionListener target="#{doctorMB.doctor}" value="#{doc}"/>
							</p:commandButton>
						</p:column>
					</p:dataTable>
				</p:panel>
			</h:form>
		</ui:define>
	</ui:composition>
</body>
</html>
